"use strict";

(function () {
  function r(e, n, t) {
    function o(i, f) {
      if (!n[i]) {
        if (!e[i]) {
          var c = "function" == typeof require && require;
          if (!f && c) return c(i, !0);
          if (u) return u(i, !0);
          var a = new Error("Cannot find module '" + i + "'");
          throw a.code = "MODULE_NOT_FOUND", a;
        }

        var p = n[i] = {
          exports: {}
        };
        e[i][0].call(p.exports, function (r) {
          var n = e[i][1][r];
          return o(n || r);
        }, p, p.exports, r, e, n, t);
      }

      return n[i].exports;
    }

    for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) {
      o(t[i]);
    }

    return o;
  }

  return r;
})()({
  1: [function (require, module, exports) {
    "use strict";

    loader.define(['pages/config/config'], function (config, require, exports, module, global) {
      var pageview = {};

      pageview.init = function () {
        var gname,
            groupid = '36';
        bui.getPageParams(function (res) {
          gname = res.gname;
        });
        $(".name-main #gname").attr("value", gname);
        var storage;
        storage = bui.storage({
          size: 0
        }); // 前一个记录,只有管理员从主界面过来才能修改名字

        var history = bui.history.getPrev(); // console.log($.isEmptyObject(history));
        // 历史不为空,则更新历史

        if (!$.isEmptyObject(history)) {
          storage.clear();
          var history_name = history.name;
          storage.set("hname", history_name);
        } // 获取前一个界面的名字


        history = storage.get("hname", 0);
        console.log(history);

        if (history.search('chatgroup') >= 0) {
          var gnameInput = bui.input({
            id: ".gname-input",
            callback: function callback(e) {
              // 清空数据
              this.empty();
            }
          });
          $("#name-btn").on("click", function (e) {
            var groupname = $(".name-main .gname-input #gname").attr("value");
            console.log(groupname);
            var data_ = {
              groupid: groupid,
              // mobile
              groupname: groupname // password

            };
            data_ = JSON.stringify(data_);
            bui.ajax({
              // url: 相对路径
              url: config.apiurl + "api/v1.0/refreshGroupName",
              data: data_,
              method: "post",
              headers: {
                'Content-Type': 'application/json'
              }
            }).then(function (res) {
              console.log(res);
              bui.hint(res.errmsg);
            }, function (res, status) {
              console.log(status);
            });
          });
        } else {
          $("#name-btn").hide();
        }
      };

      pageview.init();
      return pageview;
    });
  }, {}]
}, {}, [1]);